export function transTree(arr) {
  const newArr = []
  const map = {}
  arr.forEach(item => {
    map[item.id] = item
    map[item.id].children = []
  })
  // 遍历数组去通过pid匹配id
  arr.forEach(item => {
    if (map[item.pid]) {
      map[item.pid].children.push(item)
    } else {
      newArr.push(item)
    }
  })
  return newArr
}

